package com.sky.mapper;

import com.sky.annotation.FillBaseFields;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    @FillBaseFields(OperationType.INSERT) // 自动填充基本字段
    void insertWithFlavor(Dish dish);

    List<DishVO> selectForPage(DishPageQueryDTO dishPageQueryDTO);

    List<Dish> selectByIds(List<Long> ids);

    void deleteByIds(List<Long> ids);

    @FillBaseFields(OperationType.INSERT) // 自动填充基本字段
    void update(Dish dish);
}
